package com.example.mybaseapp.ui

import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.mybaseapp.R
import com.example.mybaseapp.util.match.StringUtil

class FuzzScopeActivity : AppCompatActivity() {
    private lateinit var datas:String
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_fuzz_scope)
        getData()
        initData()
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }

    private lateinit var tx1:TextView
    private lateinit var tx2:TextView
    private lateinit var ed1:EditText
    private fun initData() {
        ed1 = findViewById(R.id.ed_tx)
        tx1 = findViewById(R.id.tx1)
        tx2 = findViewById(R.id.tx2)
        tx2.setText("匹配文字：\n$datas")
        findViewById<Button>(R.id.btn_search).apply {
            setOnClickListener {
                startMatch()
            }
        }

    }

    /**
     * 开始匹配
     */
    private fun startMatch() {
        val s = StringUtil.getBlurMatchStr(datas,ed1.text.toString(),0.8f)
        tx1.setText("匹配结果：${s[0]} ${s[1]} ${s[2]}")
    }

    private fun getData(){
        datas = "拆掉传统直播"
    }


}